home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 February: Technology Seed / Mac Tech Seed Feb '97.toast / OpenDoc 1.2b2c1 / OpenDoc / OpenDoc Utilities / Interfaces / PasclStr.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-01  |  3.2 KB  |  125 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        PasclStr.h
  3.  
  4.     Contains:    Pascal string manipulation routines
  5.  
  6.     Owned by:    Nick Pilch
  7.  
  8.     Copyright:    © 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <2>     5/24/96    jpa        1.1MRD: pragma internal.
  13.     
  14. */
  15.  
  16. #ifndef _PASCLSTR_
  17. #define _PASCLSTR_
  18.  
  19. #ifndef _ODTYPES_
  20. #include "ODTypes.h"
  21. #endif
  22.  
  23. #ifdef THINK_CPLUS
  24.     #ifndef __pascal__
  25.     #include <pascal.h>
  26.     #endif
  27. #else // THINK_CPLUS
  28.     #ifndef __STRINGS__
  29.     #include <strings.h>
  30.     #endif
  31. #endif // THINK_CPLUS
  32.  
  33. #ifndef __TYPES__
  34. #include <types.h>
  35. #endif
  36.  
  37. #ifndef _ITEXT_
  38. #include <IText.h>
  39. #endif
  40.  
  41.  
  42. #ifdef __cplusplus
  43.     // These routines convert the string in place.
  44.     
  45.     inline StringPtr CToPascalString(char* string)
  46.     {
  47.         return c2pstr(string);
  48.     }
  49.     
  50.     inline char* PascalToCString(StringPtr string)
  51.     {
  52.         return p2cstr(string);
  53.     }
  54.  
  55.     extern "C" {
  56.  
  57. #else
  58.     #define CToPascalString    c2pstr
  59.     #define PascalToCString p2cstr
  60. #endif
  61.  
  62.  
  63. #ifdef _OD_IMPL_SHARE_UTILS_
  64. #pragma import on
  65. #elif defined(PRAGMA_INTERNAL_SUPPORTED)
  66. #pragma internal on
  67. #endif
  68.  
  69. void ConcatPascalStrings(Str255 destString, ConstStr255Param srcString);
  70.     // Error checking is done to ensure that the limit of 256 chars is not
  71.     //    exceeded.
  72.  
  73. void CopyPascalString(Str255 destString, ConstStr255Param srcString);
  74.  
  75. ODBoolean EqualPascalStrings(ConstStr255Param str1, ConstStr255Param str2);
  76.     // Returns kODTrue if strings are equal, kODFalse otherwise. Does a CASE-
  77.     //    INSENSITIVE compare!
  78.  
  79. void CopyISOStr2PStr(Str255 destString, const ODISOStr srcString);
  80.  
  81. StringPtr IntlToPStr(ODIText* intlText, StringPtr pstr);
  82.     // Caller must allocate storage for pstr. No error checking is done for
  83.     //    strings longer than 255 chars. Simply grabs the text from the theText
  84.     //    field of ODIText.
  85.     //    CAUTION: This function is only intended to convert the bytes of the
  86.     //    IText to a pascal string. These bytes are not valid without the
  87.     //    accompanying script code and language code as well.
  88.  
  89. ODIText* PStrToIntl(StringPtr pstr, ODIText** intlText);
  90.     // Caller must dispose storage for intlText when done with it. The ODIText
  91.     //    is created with theScriptCode = smScriptRoman and
  92.     //    theLangCode = langEnglish.  Storage for the ODIText is allocated only if
  93.     //  intlText == NULL; otherwise it's assumed that *intlText is a valid ptr to
  94.     //  an ODIText big enough to hold the string.
  95.     //    CAUTION: This function is only intended to convert the bytes of the
  96.     //    pascl string to the bytes in an ODIText. These bytes are not valid
  97.     //    without first setting the appropriate accompanying script code and
  98.     //    language code in the ODIText as well.
  99.  
  100. ODHandle PStrToText(ConstStr255Param pstr);
  101.     // Caller must dispose of the returned ODHandle.
  102.  
  103. void TextToPStr(ODHandle textHandle, Str255 destString);
  104.  
  105. ODSShort ClipStringToBytes( Str255 string, ODSShort numBytes,
  106.         ODScriptCode scriptCode );
  107.     // Truncate a pascal string so that it occupies the given number of bytes
  108.     // (plus the length byte) or one less.  The one less case occurs when
  109.     // simple truncation would clip off the second byte of a double-byte
  110.     // character.
  111.     // returns the number of bytes the truncated string is long, ie numBytes or
  112.     // numBytes - 1.
  113.  
  114. #ifdef __cplusplus
  115. }
  116. #endif
  117.  
  118. #ifdef _OD_IMPL_SHARE_UTILS_
  119. #pragma import off
  120. #elif defined(PRAGMA_INTERNAL_SUPPORTED)
  121. #pragma internal reset
  122. #endif
  123.  
  124.  
  125. #endif // _PASCLSTR_